//导入路由懒加载

import type { RouteRecordRaw } from 'vue-router'

//首页
const Home = () => import('@/pages/home/index.vue')
//搜索页
const Search = () => import('@/pages/search/index.vue')
//详情页
const Detail = () => import('@/pages/detail/index.vue')
//添加成功跳转
const AddCartSuccess = () => import('@/pages/AddCartSuccess/index.vue')
//购物车
const Cart = () => import('@/pages/cart/index.vue')
//交易页
const Trade = () => import('@/pages/trade/index.vue')
//支付页
const Pay = () => import('@/pages/pay/index.vue')
//支付成功
const PaySuccess = () => import('@/pages/paysuccess/index.vue')
//个人中心
const Center = () => import('@/pages/center/index.vue')
//登录页
const Login = () => import('@/pages/login/index.vue')
//注册页
const Register = () => import('@/pages/register/index.vue')
//测试页
const Test = () => import('@/pages/test/index.vue')
//404
const Error = () => import('@/pages/error/index.vue')

//导出路由
const routes: RouteRecordRaw[] = [
  {
    path: '/', //地址栏路径
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home,
    name: 'home',
    meta: {
      title: '首页'
    }
  },
  {
    path: '/center',
    component: Center,
    name: 'center',
    meta: {
      title: '个人中心'
    }
  },
  {
    path: '/login',
    component: Login,
    name: 'login',
    meta: {
      title: '登录页',
      isHidden: true
    }
  },
  {
    path: '/register',
    component: Register,
    name: 'register',
    meta: {
      title: '注册页',
      isHidden: true
    }
  },
  {
    path: '/search',
    component: Search,
    name: 'search',
    meta: {
      title: '搜索页'
    }
  },
  {
    path: '/detail/:id',
    component: Detail,
    name: 'detail',
    meta: {
      title: '详情页'
    }
  },
  {
    path: "/addcartsuccess",
    component: AddCartSuccess,
    name: 'addcartsuccess',
    meta: {
      title: '详情页面添加成功跳转'
    }
  },
  {
    path: '/addToCart',
    component: Cart,
    name: 'cart',
    meta: {
      title: '购物车'
    }
  },
  {
    path: '/trade',
    component: Trade,
    name: 'trade',
    meta: {
      title: '交易页'
    }
  },
  {
    path: '/pay',
    component: Pay,
    name: 'pay',
    meta: {
      title: '支付页'
    }
  },
  {
    path: '/paysuccess',
    component: PaySuccess,
    name: 'paysuccess',
    meta: {
      title: '支付页'
    }
  },
  {
    path: '/test',
    component: Test,
    name: 'test',
    meta: {
      title: '测试页'
    }
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'Any',
    component: Error,
    meta: {
      title: '404',
      isHidden:true
    }
  }
]

export default routes